/**
 * 
 */
package org.william.common_boot.task.control;

import java.util.concurrent.Future;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.william.common_boot.task.service.impl.AsyncTask;

/** 
 * 异步
 * Description: 
 * @author xuhongwei
 * @version 1.0
 * <pre>
 * Modification History: 
 * Date         Author      Version     Description 
------------------------------------------------------------------
 * 2018年8月2日    xuhongwei     1.0        1.0 Version 
 * </pre>
 */
@RestController
@RequestMapping("doTask")
public class DoTask {
		
	@Autowired
	AsyncTask asyncTask;
	
    @RequestMapping("test1")
	public String test1() throws Exception{
		
		long start = System.currentTimeMillis();
		
		Future<Boolean> a = asyncTask.doTask11();

		Future<Boolean> b = asyncTask.doTask22();

		Future<Boolean> c = asyncTask.doTask33();

		while (!a.isDone() || !b.isDone() || !c.isDone()) {
			if (a.isDone() && b.isDone() && c.isDone()) {
				break;
			}
		}

		long end = System.currentTimeMillis();

		String times = "任务全部完成，总耗时：" + (end - start) + "毫秒";

		System.out.println(times);

		return times;
	}

}
